<?php
function SendInfo($var)
{
	global $callback;
	echo "($callback)(\"$var\")";
}

function SendError()
{
	SendInfo(mysql_error());
}

function InsertVal($key, $val)
{
	global $con;
	global $table;
	if(!$con) return false;
	$ret = @mysql_select_db($table, $con);
	if(!$ret) return false;
	$sql = "INSERT INTO `keyval` (`Key`, `Val`) VALUES ('$key', '$val') ON DUPLICATE KEY UPDATE `Val` = '$val' ";	
	$ret = @mysql_query($sql);
	@mysql_close($con);
	return $ret;	
}

include("KeyValueConn.php");

$val = $_REQUEST['val'];

$ret = InsertVal($key, $val);
if($ret) SendInfo('UPDATE');
else SendError();

?>